package Dungeoneering.PathFinding.DataStructures;

import Dungeoneering.Entities.Room;
import Dungeoneering.Entities.Room.Direction;

/**
 * this is one node in our 4-tree
 * @author Nicolaas
 *
 */
class TreeNode { // package protected
	
	private Room object;
	private TreeNode north;
	private TreeNode east;
	private TreeNode south;
	private TreeNode west;
	
	public TreeNode(Room room) {
		this.object = room;
	}
	
	public Room get() {
		return object;
	}
	
	public TreeNode get(Direction direction) {
		switch (direction) {
		case NORTH:
			return north;
		case EAST:
			return east;
		case SOUTH:
			return south;
		case WEST:
			return west;
		default:
			return null;
		}
		
	}
	
	public void setLink(TreeNode node, Direction direction) {
		switch (direction) {
		case NORTH:
			north = node;
		case EAST:
			east = node;
		case SOUTH:
			south = node;
		case WEST:
			west = node;
		}
	}
	
	public boolean hasLink(Direction direction) {
		switch (direction) {
		case NORTH:
			return north == null;
		case EAST:
			return east == null;
		case SOUTH:
			return south == null;
		case WEST:
			return west == null;
		}
		return false;
	}

}
